﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style x:Key="CheckRadioFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="0"
                               SnapsToDevicePixels="true"
                               Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
                               StrokeThickness="1"
                               StrokeDashArray="1 2" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="FlatRadioButtonStyle"
           TargetType="{x:Type ToggleButton}">
        <Setter Property="Foreground"
                Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
        <Setter Property="Background"
                Value="#F4F4F4" />
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="HorizontalContentAlignment"
                Value="Center" />
        <Setter Property="VerticalContentAlignment"
                Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid>
                		<VisualStateManager.VisualStateGroups>
                			<VisualStateGroup x:Name="CommonStates">
                				<VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver"/>
                                <VisualState x:Name="Pressed"/>
                				<VisualState x:Name="Disabled"/>
                			</VisualStateGroup>
                			<VisualStateGroup x:Name="CheckStates">
                				<VisualState x:Name="Checked">
                					<Storyboard>
                						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="border">
                							<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
                						</ObjectAnimationUsingKeyFrames>
                					</Storyboard>
                				</VisualState>
                				<VisualState x:Name="Unchecked"/>
                				<VisualState x:Name="Indeterminate"/>
                			</VisualStateGroup>
                		</VisualStateManager.VisualStateGroups>
                		<Border x:Name="border" BorderBrush="Black" Background="{TemplateBinding Background}" Visibility="Hidden" />
                		<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                			RecognizesAccessKey="True"
                			VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                	</Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasContent"
                                 Value="true">
                            <Setter Property="FocusVisualStyle"
                                    Value="{StaticResource CheckRadioFocusVisual}" />
                            <Setter Property="Padding"
                                    Value="4,0,0,0" />
                        </Trigger>
                        <Trigger Property="IsEnabled"
                                 Value="false">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="TileRadioButtonStyle"
           TargetType="{x:Type ToggleButton}"
           BasedOn="{StaticResource FlatRadioButtonStyle}">
    	<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HotTrackBrushKey}}"/>
    	<Setter Property="BorderThickness" Value="0"/>
    	<Setter Property="BorderBrush" Value="{x:Null}"/>
        <Style.Triggers>
            <Trigger Property="IsChecked"
                     Value="True">
                <Setter Property="Foreground"
                        Value="White" />
            </Trigger>
        </Style.Triggers>
    </Style>
    
</ResourceDictionary>